package com.woniu.user.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.user.commons.Result;
import com.woniu.user.model.CoachApply;
import com.woniu.user.service.CoachApplyService;
import com.woniu.user.util.JwtUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 教练登记申请表 前端控制器
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/coachApply")
@Slf4j
public class CoachApplyController {
    @Resource
    private CoachApplyService coachApplyService;

    @PostMapping("/successBeCoach")
    public Result successBeCoach(@RequestBody Integer coachApplyId) {
        log.info("成为教练申请通过{}", coachApplyId);
        coachApplyService.successBeCoach(coachApplyId);
        return Result.success(200, "申请成功", null);
    }

    @GetMapping("/query")
    public Result query(HttpServletRequest req) {
        Integer userId = JwtUtil.getUserIdFromReq(req);// 获取用户账号
        List<CoachApply> query = coachApplyService.query(userId);
        return Result.success(200, "查询成功", query);
    }
}

